﻿using BackData;
using Domain.BOM;
using Infratructure;
using MediatR;
using Team.API.Applocation.Command.Quality;

namespace Team.API.Applocation.Hanldler.Quality
{
    public class GetBomHandler : IRequestHandler<GetBomCommand, APIResult<List<Bomtable>>>
    {
        private readonly IRepository<Bomtable> bomRep;

        public GetBomHandler(IRepository<Bomtable> bomRep)
        {
            this.bomRep = bomRep;
        }
        public async Task<APIResult<List<Bomtable>>> Handle(GetBomCommand request, CancellationToken cancellationToken)
        {
            var list = bomRep.GetAll().Where(x => !x.IsDel);
            return new APIResult<List<Bomtable>>
            {
                Code = StateCode.OK,
                Result = list.ToList(),
                Message = "获取成功"
            };
        }
    }
}
